#include <iostream>
using namespace std;
string s1, s2, s3, s4;
int t, k;
int main(){
	cin >> t;
	while(t--){
		cin >> s1 >> s2;
		k = 0;
		int len = min(s1.size(), s2.size());
		for (int i = 0; i < len; i++){
			if (s1[i] == s2[i]) k++;
			else break;
		}
		if (k) cout << s1.size() + s2.size() - k + 1 << endl;
		else cout << s1.size() + s2.size() << endl;
		
	}
	return 0;
}
